#include <dbg.h>

#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

class Solution {
public:
    bool uniqueOccurrences(vector<int>& arr) {
        unordered_map<int, int> occur;  // <数组中的元素值，该元素出现的次数>
        for (const auto& x : arr) {
            ++occur[x];
        }

        unordered_set<int> times;  // 用于存储不同的出现次数
        for (const auto& x : occur) {
            times.insert(x.second);
        }

        dbg(times, occur);

        return times.size() == occur.size();
    }
};

int main() {
    Solution s;

    vector<int> arr1{1, 2, 2, 1, 1, 3};
    vector<int> arr2{1, 2};
    vector<int> arr3{-3, 0, 1, -3, 1, 1, 1, -3, 10, 0};

    assert(s.uniqueOccurrences(arr1) == true);
    assert(s.uniqueOccurrences(arr2) == false);
    assert(s.uniqueOccurrences(arr3) == true);

    return 0;
}